<template>
  <div class="detailContainer">
    <div
      style="
        height: 100%;
        padding-left: 150px;
        padding-right: 150px;
        overflow-y: auto;
        padding-bottom: 70px;
      "
    >
      <div style="padding: 20px">
        <el-card>
          <div style="display: flex; justify-content: space-between">
            <div>
              <div class="title">
                <span class="name">{{ detailData.name }}</span>
                <span class="id">{{ detailData.id }}</span>
              </div>
              <div class="detailInfo">
                <div class="createInfo">
                  <span style="font-size: 15px"
                    >创建人：<span style="font-size: 14px; color: #969696">{{
                      detailData.creator
                    }}</span></span
                  >
                  <span style="font-size: 15px; margin-left: 20px"
                    >创建时间：<span style="font-size: 14px; color: #969696">{{
                      detailData.createTime
                    }}</span></span
                  >
                </div>
                <div class="updateInfo">
                  <span style="font-size: 15px"
                    >更新人：<span style="font-size: 14px; color: #969696">{{
                      detailData.updater
                    }}</span></span
                  >
                  <span style="font-size: 15px; margin-left: 20px"
                    >更新时间：<span style="font-size: 14px; color: #969696">{{
                      detailData.updateTime
                    }}</span></span
                  >
                </div>
              </div>
              <div class="buttonGroup" style="margin-top: 20px">
                <el-button type="primary" plain style="width: 80px"
                  >撤回</el-button
                >
                <el-button type="primary" plain style="width: 80px"
                  >打印</el-button
                >
              </div>
            </div>
            <div>
              <img
                style="width: 80px"
                :src="`/public/putImgs/${
                  detailData.status == '未入库' ? 'noPut.png' : 'put.png'
                }`"
                alt=""
              />
            </div>
          </div>
        </el-card>
        <el-card style="margin-top: 20px">
          <template #header>
            <span style="font-size: 16px">入库详情</span>
          </template>
          <div class="basicBody">
            <div class="basicInfoContainer">
              <div class="milestone">
                <div class="milestone-content">基础信息</div>
              </div>
              <el-descriptions
                style="margin-top: 40px; width: 100%"
                column="2"
                label-width="120"
              >
                <el-descriptions-item label="入库单编号">{{
                  detailData.storageCode
                }}</el-descriptions-item>
                <el-descriptions-item label="入库单名称">{{
                  detailData.storageName
                }}</el-descriptions-item>
                <el-descriptions-item label="入库日期">{{
                  detailData.storageDate
                }}</el-descriptions-item>
                <el-descriptions-item label="工单名称">{{
                  detailData.workOrderName
                }}</el-descriptions-item>
                <el-descriptions-item label="工单编号">{{
                  detailData.workOrderCode
                }}</el-descriptions-item>
                <el-descriptions-item label="备注">{{
                  detailData.remark
                }}</el-descriptions-item>
              </el-descriptions>
            </div>
            <div class="warehouseContainer">
              <div class="milestone">
                <div class="milestone-content">入库明细</div>
              </div>
              <el-descriptions
                style="margin-top: 40px; width: 100%"
                column="2"
                label-width="120"
              >
                <el-descriptions-item label="产品名称">{{
                  detailData.productName
                }}</el-descriptions-item>
                <el-descriptions-item label="产品编号">{{
                  detailData.productCode
                }}</el-descriptions-item>
                <el-descriptions-item label="规格型号">{{
                  detailData.specification
                }}</el-descriptions-item>
                <el-descriptions-item label="产品类型">{{
                  detailData.productType
                }}</el-descriptions-item>
                <el-descriptions-item label="单位">{{
                  detailData.unit
                }}</el-descriptions-item>
                <el-descriptions-item label="批次号">{{
                  detailData.batchNumber
                }}</el-descriptions-item>
                <el-descriptions-item label="入库数量">{{
                  detailData.quantity
                }}</el-descriptions-item>
                <el-descriptions-item label="生产日期">{{
                  detailData.productDate
                }}</el-descriptions-item>
                <el-descriptions-item label="到期日期">{{
                  detailData.endDate
                }}</el-descriptions-item>
                <el-descriptions-item label="仓库名称">{{
                  detailData.warehouseName
                }}</el-descriptions-item>
                <el-descriptions-item label="库区名称">{{
                  detailData.areaName
                }}</el-descriptions-item>
                <el-descriptions-item label="库位名称">{{
                  detailData.locationName
                }}</el-descriptions-item>
                <el-descriptions-item label="仓库负责人">{{
                  detailData.leader
                }}</el-descriptions-item>
              </el-descriptions>
            </div>
          </div>
        </el-card>
      </div>
    </div>
    <div class="footer" :class="{ 'footer-visible': isFooterVisible }">
      <div class="footerButton">
        <el-button type="primary" plain style="width: 80px" @click="close"
          >关闭</el-button
        >
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRoute, useRouter } from "vue-router";
import { onMounted, ref } from "vue";
import { productStorageResultsData } from "@/api/productStorage/res";
import { getproductStorageListApi } from "@/api/productStorage";
import { ElMessage } from "element-plus";
const $router = useRouter();
const route = useRoute();
let objectId = "";

//mockData
let detailData = ref<productStorageResultsData>({
  productlistId: "",
  storageName: "",
  storageCode: "",
  storageDate: "",
  workOrderName: "",
  workOrderCode: "",
  productName: "",
  productCode: "",
  specification: "",
  unit: "",
  batchNumber: "",
  quantity: "",
  warehouseName: "",
  areaName: "",
  locationName: "",
  status: "",
  remark: "",
  leader: "",
  productDate: "",
  endDate: "",
  productType: "",
});
let tableData = ref([{}]);
const isFooterVisible = ref(false);
const close = () => {
  $router.replace("/storage/entrance/product");
};

onMounted(async () => {
  setTimeout(() => {
    isFooterVisible.value = true;
  }, 100);
  try {
    const res = await getproductStorageListApi({ objectId: objectId });
    detailData.value = res.results[0];
  } catch (err: any) {
    console.log(err);
    ElMessage.error("获取数据失败");
  }
});
</script>

<style scoped lang="scss">
.detailContainer {
  width: 100%;
  position: relative;
  height: 100%;
  transform: translate(0);
  .title {
    .name {
      font-weight: bold;
      font-size: 18px;
    }
    .id {
      color: #969696;
      font-size: 13px;
      margin-left: 10px;
    }
  }
  .detailInfo {
    margin-top: 10px;
    display: flex;
  }
  .updateInfo {
    margin-left: 40px;
  }
  .basicBody {
    width: 100%;
    .basicInfoContainer,
    .warehouseContainer {
      padding: 20px;
      .milestone {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 1.5px;
        background-color: #dfe2e7;
        .milestone-content {
          border: 1.5px solid #dfe2e7;
          padding: 10px;
          padding-left: 20px;
          padding-right: 20px;
          font-weight: bold;
          font-size: 15px;
          border-radius: 10px;
          z-index: 999;
          background-color: #fff;
          color: #1b9aee;
        }
      }
    }
    .warehouseContainer {
      margin-top: 20px;
    }
  }
  .footer {
    z-index: 999;
    width: 100%;
    height: 70px;
    background-color: #fff;
    position: fixed;
    bottom: 0;
    left: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    box-shadow: 0 -8px 10px rgba(92, 92, 92, 0.1);
    transform: translateY(100%); // 初始状态在视口下方
    transition: transform 0.5s ease-out; // 添加过渡效果

    &.footer-visible {
      transform: translateY(0); // 显示时回到原位
    }
  }
}
</style>
